package jp.ne.hatena.d.digitalsoul.warikan.contexts.rootpopulaters

import jp.ne.hatena.d.digitalsoul.warikan.models._
import jp.ne.hatena.d.digitalsoul.warikan.repositories._

trait PartyPopulater {
	
	def populateParty(role:Object):Party = {
		val party:Party = role.asInstanceOf[Party]
		populate(party)
		party
	}
	
	
	private def populate(party:Party) = {
		if(PartyRepository.exists(party.id)) 
			party.populateWith(PartyRepository.forPartyId(party.id))
	}
	
}